<template>
	<view class="content">

		<image class="img_header" :src="avatar"></image>

		<view class="u_name">{{nickname || '--'}}</view>

		<view style="display: none;" class="u_name">{{tel || '--'}}</view>

		<view class="menu_div" @click.stop="onZJQuery">
			<view class="menu_txt">中奖查询</view>
			<image class="img_arrow" src="/static/ic_right_arrow.png"></image>
		</view>

		<view class="divider" />

		<!-- 站点人员核销专用 -->
		<view class="menu_div" @click.stop="onHexiao">
			<view class="menu_txt">中奖核销</view>
			<image class="img_arrow" src="/static/ic_right_arrow.png"></image>
		</view>

		<view class="divider" />

		<view v-if="getUId()" class="btn_ok" @click.stop="onOk(1)">退出登录</view>
		<view v-else class="btn_ok" @click.stop="onOk(2)">站点登录</view>

	</view>
</template>

<script>
	import { getUInfo } from '@/util/util.js'
	export default {
		data() {
			return {
				nickname: '',
				tel: '',
				avatar: '/static/ic_login_logo.png',
			}
		},

		onLoad() {
			let that = this

			this.nickname = getUInfo().nickname
			this.tel = getUInfo().tel
			// this.avatar = getUInfo().avatar
		},

		methods: {

			onZJQuery() {
				// uni.showToast({ title: '中奖查询', icon: 'none' })
				uni.navigateTo({ url: '/pages/pz/qr' })
			},

			onHexiao() {
				// if (!this.getUId()) {
				// 	uni.navigateTo({ url: '/pages/login/login' })
				// 	return
				// }
				// uni.navigateTo({ url: '/pages/sys/scan_qrcode' })
				location.href = 'https://zsycsb.xman56.com/#/pages/login/login'
			},

			onOk(flag) {
				let content = flag == 2 ? '前往登录页面？' : '是否退出登录？'
				uni.showModal({
					title: '提示',
					content,
					success: res => {
						if (res.confirm) {
							uni.removeStorageSync('userinfo')
							uni.redirectTo({ url: '/pages/login/login' })
						}
					}
				})
			},

			// 接口:  }$postSiteLogin

			getUId() {
				return getUInfo().id
			},

		}
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.img_header {
		width: 160rpx;
		height: 160rpx;
		margin: 100rpx 0 0 0;
		border-radius: 888rpx;
	}

	.u_name {
		font-size: 30rpx;
		margin: 20rpx 0 0 0;
	}

	.btn_ok {
		background: #6974DD;
		width: 550rpx;
		height: 88rpx;
		line-height: 88rpx;
		color: white;
		text-align: center;
		font-size: 30rpx;
		margin: 60rpx 0 0 0;
		border-radius: 888rpx;
	}

	.menu_div {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 110rpx;
		margin: 0rpx 0 0 0;
	}

	.menu_txt {
		font-size: 28rpx;
		margin: 0 0 0 30rpx;
	}

	.img_arrow {
		width: 30rpx;
		height: 30rpx;
		margin: 0 30rpx 0 0;
	}

	.divider {
		width: calc(100% - 60rpx);
		height: 1rpx;
		background-color: rgba(1, 1, 1, 0.12);
		margin: 0 30rpx 0 30rpx;
	}
</style>